program List;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  pelement=^element;
  element=record
    value:integer;
    next:pelement;
  end;

procedure addToBegin(var head:pelement; num:integer);

var
 tmp:pelement;

begin
  tmp:=head;
  new(head);
  head^.value:=num;
  head^.next:=tmp;
end;

function deleteFromBegin(var head:pelement):integer;

var
  tmp:pelement;

begin
  if head<>nil then
  begin
    tmp:=head;
    head:=head^.next;
    deleteFromBegin:=tmp^.value;
    dispose(tmp);
  end;
end;

procedure printList(head:pelement);

var
  current:pelement;

begin
  current:=head;
  while(current<>nil) do
  begin
    writeln(current^.value);
    current:=current^.next;
  end;
end;

var
  head, slave:pelement;
  N,a,i:integer;

begin
  readln(N);
  new(head);
  for i:=1 to N do
  begin
    read(a);
    addToBegin(head,a);
  end;
  printList(head);
  for i:=1 to N do
    deleteFromBegin(head);
  dispose(head);
end.
